{extend name="Public:base"/}

{block name="main"}
<div class="box-info">
    <form id="myform" action="{:U('User/add')}" method="post">
        <div class="form-group row">
            <label class="form-control-label col-md-2">用户名</label>
            <div class="col-md-5">
                <input type="text" class="form-control" name="username" value="" >
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2">密码</label>
            <div class="col-md-5">
                <input type="password" id="password" name="password" class="form-control" />
            </div>
        </div>

        <div class="form-group row">
            <label class="form-control-label col-md-2">邮箱</label>
            <div class="col-md-5">
                <input type="text" class="form-control" name="email">
            </div>
        </div>

        <div class="form-group row">
            <label class="form-control-label col-md-2">手机</label>
            <div class="col-md-5">
                <input type="text" class="form-control" name="mobile">
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2">会员组</label>
            <div class="col-md-5">
                <select name="group_id" class="form-control">
                    {volist name="userGroups" id="vo"}
                    <option value="{$vo['id']}">{$vo['name']}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2">是否激活</label>
            <div class="col-md-5">
                <label class="radio-inline">
                    <input type="radio" name="status" checked value="1"  />是
                </label>
                <label class="radio-inline">
                    <input type="radio" name="status" value="0" />否
                </label>
            </div>
        </div>
        <div class="form-actions">
            <button type="submit" class="btn btn-primary">提交</button>
            <button type="button" class="btn btn-danger" onclick="javascript:history.back(-1);return false;">返回</button>
        </div>
    </form>
</div>
{/block}

{block name="script"}
    <script type="text/javascript">
        $(document).ready(function() {
            $('#myform').ajaxForm({
                success:  complete,  // post-submit callback
                dataType: 'json'
            });
        });

        function complete(data){
            if (data.status == 1) {

                layer.confirm(data.info, {
                    icon:1,
                    btn: ['继续添加','返回列表'] //按钮
                }, function(){
                    window.location.href = "{:U('User/add')}";
                    return false;
                }, function(){
                    window.location.href = "{$Think.cookie.__forward__}";
                    return true;
                });

            } else {
                layer.msg(data.info, {icon: 2});
            }
        }
    </script>
    {/block}